#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jul  2 11:11:22 2018

@author: chenliheng
"""

from functools import reduce

# reduce函数实现遍历集合时进行数值累积运算
# 参数x:上一次运算结果或初始值
# 参数y:集合中下一个元素
func = lambda x,y:x+y

result = reduce(func, [1, 2, 3, 4, 5])

print(result)
